package tech.eyao.hs60x.enums;

/**
 * @author hejian
 * @date 2017年12月20日 上午10:24:48
 */
public enum ApprovalStatus {
    NO("FREE", 1, "未审批"),
    YES("ALLOW", 2, "通过"),
    REFUSE("REFUSE", 3, "拒绝");
    
    private String key;
    private int    value;
    private String desc;

    public static ApprovalStatus getByValue(int value) {
        for (ApprovalStatus type : ApprovalStatus.values()) {
            if (type.value == value) {
                return type;
            }
        }
        return null;
    }

    /**
     * 获取审批状态
     * 
     * @param key
     * @return
     */
    public static ApprovalStatus getValueByKey(String key) {
        for (ApprovalStatus type : ApprovalStatus.values()) {
            if (type.key.equals(key.toUpperCase())) {
                return type;
            }
        }
        return null;
    }

    private ApprovalStatus(String key, int value, String desc) {
        this.key = key;
        this.value = value;
        this.desc = desc;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public int getValue() {
        return value;
    }

    public void setValue(int value) {
        this.value = value;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

}
